﻿Public Class AutoCADCommandHandler
    Implements System.Windows.Input.ICommand
    Private _command As String = ""

    Public Sub New(ByVal cmd As String)
        _command = cmd
    End Sub

    Public Event CanExecuteChanged As EventHandler Implements System.Windows.Input.ICommand.CanExecuteChanged

    Public Function CanExecute(ByVal parameter As Object) As Boolean Implements System.Windows.Input.ICommand.CanExecute
        Return True
    End Function

    Public Sub Execute(ByVal parameter As Object) Implements System.Windows.Input.ICommand.Execute
        If Not [String].IsNullOrEmpty(_command) Then
            Dim doc As Autodesk.AutoCAD.ApplicationServices.Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
            doc.SendStringToExecute(_command & " ", False, False, False)
        End If
    End Sub
End Class
